/*
 * @Author: nengwu 409791297@qq.com
 * @Date: 2020-06-24 10:19:52
 * @LastEditors: mylesshie@gmail.com
 * @LastEditTime: 2020-07-03 13:11:27
 * @description:
 */
import {
  GET_COLUMNS,
  GET_ARTICLES,
  GET_ARTICLE_DETAIL,
  GET_BANNERS
} from '@/constants/main'

let INIT_STATE = {
  columns: {
    firstPage: [{}],
    livePage: [{}]
  },
  homeBanners: [],
  homeArticleList: [],
  homePageInfo: {
    pageNum: 1,
    pageSize: 20
  },
  detail: {}
}

export default function main(state = INIT_STATE, action) {
  switch (action.type) {
    case GET_COLUMNS:
      return {
        ...state,
        columns: action.data
      }
    case GET_BANNERS:
      return {
        ...state,
        homeBanners: action.data
      }
    case GET_ARTICLES:
      return {
        ...state,
        homeArticleList: action.data.list,
        homePageInfo: {
          pageNum: action.data.pageNum,
          pageSize: action.data.pageSize
        }
      }
    case GET_ARTICLE_DETAIL:
      return {
        ...state,
        detail: action.data
      }
    default:
      return state
  }
}
